package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.mapper.MornMapper;
import com.xxx.modules.entity.Morn;
import com.xxx.modules.service.MornService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * morn
 *
 * @author 北易航
 * @since 1.0.0 2023-01-21
 */
@Service
public class MornServiceImpl extends ServiceImpl<MornMapper, Morn> implements MornService {

    @Autowired
    private MornMapper mornMapper;


    @Override
    public PageInfo<Morn> selectMornInfo(Morn morn, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Morn> wrapper = new QueryWrapper<>();
        List<Morn> data = mornMapper.selectListInfo(morn);
        return new PageInfo<>(data);
    }

    @Override
    public void saveMornInfo(Morn morn) {
        morn.setCreateTime(TimeUtil.getCurrentTime());
        mornMapper.insert(morn);
    }

    @Override
    public void updateMornInfo(Morn morn) {
        mornMapper.updateById(morn);
    }

    @Override
    public void delMornInfo(Integer id) {
        mornMapper.deleteById(id);
    }

    @Override
    public void delBatchMornInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        mornMapper.deleteBatchIds(list);
    }


}